package servlet.cuota;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import condominio.excepcion.DAOExcepcion;
import condominio.modelo.Cuota;
import condominio.modelo.Usuario;
import condominio.negocio.GestionCuotas;


@WebServlet("/CuotaEditarServlet1")
public class CuotaEditarServlet1 extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
  
    public CuotaEditarServlet1() {
        super();
        
    }


	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		HttpSession session = request.getSession();
		Usuario u = (Usuario)session.getAttribute("USUARIO_ACTUAL");
		
		if (u ==null){
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
			return;
		}
		
		
		
		
		Integer idCuota = Integer.parseInt(request.getParameter("idCuota"));
		GestionCuotas negocio = new GestionCuotas();
		try {
			Cuota vo = negocio.obtener(idCuota);
			request.setAttribute("vo", vo);
		} catch (DAOExcepcion e) {
			System.out.println(e.getMessage());
			RequestDispatcher rd = request.getRequestDispatcher("error.jsp");
			rd.forward(request, response);
		}
		RequestDispatcher rd = request.getRequestDispatcher("CuotasEditar.jsp");
		rd.forward(request, response);
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
	}

}
